package com.yl.auth.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yl.auth.model.entity.GangweiQuanxian;
import com.yl.auth.service.GangweiQuanxianService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ln
 * @since 2023-06-29
 */
@Api(tags = "人事行政-权限岗位中间表")
@RestController
@RequestMapping("/admin/auth/gangweiquanxian")
public class GangweiQuanxianController {

    @Autowired
    private GangweiQuanxianService gqservice;

    @ApiOperation("根据岗位id删除信息")
    @DeleteMapping("/del/{id}")
    public Result del(@PathVariable Long id){
        QueryWrapper queryWrapper = new QueryWrapper();
        if (id != null){
            queryWrapper.eq("gangweiid",id);
        }
        gqservice.remove(queryWrapper);
        return Result.ok();
    }

    @ApiOperation("批量添加信息")
    @PostMapping("/save")
    public Result save(@RequestBody List<GangweiQuanxian> gqList){
        boolean b = gqservice.saveBatch(gqList);
        if (b){
            return Result.ok();
        }else {
            return Result.fail();
        }
    }
}

